package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-16
 * Time: 9:06
 */
class Animal{
    public String name;
    public int age;
    public void eat(){
        System.out.println(this.name + "正在吃东西");
    }
}
class Bird extends Animal{
    //重写eat
    @Override
    public void eat() {
        System.out.println(this.name + "正在吃虫子");
    }
}
class Dog extends Animal{
    //重写eat
    @Override
    public void eat() {
        System.out.println(this.name + "正在吃骨头");
    }
}
public class Test {
    public static void func(Animal animal){
        animal.eat();
    }
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.name = "二哈";
        Bird bird = new Bird();
        bird.name = "叽叽";
        func(dog);
        func(bird);
    }
}
